/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.buzzwords.resources;

import com.buzzwords.dataaccess.Database;
import com.buzzwords.factories.BuzzwordDatabaseFactory;
import com.buzzwords.factories.DatabaseFactory;
import com.buzzwords.model.Buzzword;
import java.util.List;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import net.sf.json.JSONObject;

/**
 *
 * @author potlow
 */
@Path("/buzzword")
public class BuzzwordResource {

    @Path("/add/{name}/{defintion}/{userid}")
    @GET
    @Produces("text/plain")
    public String createBuzzword(@PathParam("name") String name, @PathParam("defintion") String definition, @PathParam("userid") Integer id) {

        Buzzword buzzword = new Buzzword();
        buzzword.setWord(name);
        buzzword.setDefinition(definition);
        buzzword.setUserId(id);

        DatabaseFactory databaseFactory = new BuzzwordDatabaseFactory();
        Database database = databaseFactory.getDatabase("Buzzword ID");
        if(database.performCreate(buzzword)) {
            return "ok";
        } else {
            return "not ok";
        }
    }
}
